import Vue from 'vue'
import router from '@/router'
import store from '@/store'

let utils = {}

/* 将时间戳格式化为yyyy-MM-dd hh:mm:ss格式，其它格式可自行更改 */
utils.formatTimeMills = (timeMills) => {
	var date = new Date(timeMills);
	var timeStr = date.getFullYear() + "-";
	if (date.getMonth() < 9) { // 月份从0开始的
		timeStr += '0';
	}
	timeStr += date.getMonth() + 1 + "-";
	timeStr += date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate();
	timeStr += ' ';
	timeStr += date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours();
	timeStr += ':';
	timeStr += date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes();
	timeStr += ':';
	timeStr += date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds();
	return timeStr;
}

export default utils;
